package com.dingding.transfer.stamper.handler;

import com.alibaba.fastjson.JSONObject;
import com.dingding.transfer.stamper.constant.EventType;
import lombok.extern.slf4j.Slf4j;

/**
 * @author wangxiyuan
 * @description 审批任务处理器 审批流程中每一个节点开始结束时 都会触发APPROVE_TASK事件
 * @createDate 2021/3/30 14:22
 **/
@Slf4j
@Deprecated
public class TaskHandler implements EventHandler{
    @Override
    public boolean support(String eventType) {
        if (EventType.APPROVE_TASK.getEventType().equals(eventType)) {
            return true;
        }
        return false;
    }

    @Override
    public boolean handle(JSONObject jsonObject) {
        try {
            // 审批为用印审批时
            /*if(StringUtils.contains(jsonObject.getString("title"),ApprovalPara.STAMPER_INFO)
            && ApprovalPara.TASK_FINISH.equals(jsonObject.getString("type"))){
                ProcessRecord processRecord = ApprovalPara.buildRecord(jsonObject);
                BusinessService businessService = SpringContextUtil.getBean(BusinessService.class);
                businessService.saveProcessRecord(processRecord);
            }*/
        } catch (Exception e) {
           log.error("任务审批事件处理器回调出现错误{}",e.getMessage());
        }
        return true;
    }
}
